const db=require("../lib/db")
 function articleList(){
     return new Promise((resolve,reject)=>{
         let sql="select * from article"
         db.querySql(sql).then(data=>{
             if(data.length==0){
                 resolve(404)
             }else{
                 let arr=[]
                 data.map(element=>{
                     arr.push({
                        _id: Buffer.from(String(element.id)).toString("Base64"),
                        title: element.title,
                        content: element.content,
                        descs: element.descs,
                        author: element.author,
                        authorId: element.authorId,
                        classify: element.classify,
                     })
                 })
                 resolve(arr)
                 console.log(arr)
             }
    })
})
}
module.exports=articleList;


// create table article(
//     _id varchar(100)  not null,
//     title varchar(100)  not null,
//     descs varchar(200)  not null,
//     author varchar(200)  not null,
//     authorId varchar(150)  not null,
//     classify varchar(100)  not null,
//     content varchar(500)  not null);


// insert into article(_id,title,descs,author,authorId,classify,content)values
//    ("a820e","防抖和节流白话文版","许多前端面试题","lilei","0ebaa","1","程序会继续触发相同的事件"),("ef69","CSS 基础","CSS 概念","admin","2d92","1","汉译层叠样式表");